use atlas
INSERT INTO tarific_tmp
  (tarific_tmp.x_25aos, tarific_tmp.x_25aps, tarific_tmp.idlc, tarific_tmp.aos, tarific_tmp.aps, tarific_tmp.nui, tarific_tmp.dbegin, tarific_tmp.tbegin, tarific_tmp.dtend, tarific_tmp.vobr, 
                      tarific_tmp.prinb, tarific_tmp.peredb, tarific_tmp.err, tarific_tmp.kod_err, tarific_tmp.sek, tarific_tmp.vb_c)
SELECT
  npered, npromezh, idlc, aos, aps, aosr, 
  dateadd([yy], 16, CONVERT(smalldatetime, dbegin, 12)), 
  dateadd([yy], 16, CONVERT(datetime, dbegin, 12) + 
  CONVERT(datetime, (substring(tbegin, 1, 2) + ':' + substring(tbegin, 3, 2) + ':' + substring(tbegin, 5, 2)), 8)), 
  dateadd([yy], 16, CONVERT(datetime, (substring(dtend, 3, 2) + '.' + substring(dtend, 5, 2) + '.' + substring(dtend, 1, 2) + ' ' +
    substring(dtend, 7, 2) + ':' + substring(dtend, 9, 2) 
      + ':' + substring(dtend, 11, 2)), 1)), vobr, prinb, peredb, LTRIM(pol7), LTRIM(pol8), vobr, vobr
FROM         collector
go
UPDATE tarific_tmp 
SET tarific_tmp.sek=(tarific_tmp.sek/10000)*3600+((tarific_tmp.sek % 10000)/100)*60+(tarific_tmp.sek % 10000) % 100
go
UPDATE tarific_tmp 
SET tarific_tmp.vb_c=(tarific_tmp.prinb+tarific_tmp.peredb)/tarific_tmp.sek
where tarific_tmp.sek <> 0
go
INSERT INTO tarific (tarific.x_25aos,tarific.x_25aps,tarific.idlc,
                     tarific.aos,tarific.aps,
                     tarific.nui,tarific.dbegin,
                     tarific.tbegin,tarific.dtend,
                     tarific.vobr,tarific.prinb,
                     tarific.peredb,tarific.err,
                     tarific.kod_err,tarific.sek,
                     tarific.vb_c)
SELECT x_25aos,x_25aps,idlc,
       aos,aps,
       nui,dbegin,
       tbegin,dtend,
       vobr,prinb,
       peredb,err,
       kod_err,sek,
       vb_c
from tarific_tmp
